< Prev(J) / Next(K) > / View :

Filename: /text/sbasic/shared/03020301.xhp

(section: eof) (bookmark: bm_id3154598)
Eof function

Eof 関数

Eof Function [Runtime]
Eof 関数 [実行時](hd_id3154598.1)

Determines if the file pointer has reached the end of a file.
ファイルポインタがファイル末尾に到達したかを確認します。(par_id3147182.2)

(/section: eof)

Syntax:
構文:(hd_id3149119.3)

Eof (intexpression As Integer)
Eof (intexpression As Integer)(par_id3147399.4)

Return value:
戻り値:(hd_id3153539.5)

Bool
ブール型(par_id3156027.6)

Parameters:
パラメータ:(hd_id3152924.7)

Intexpression: Any integer expression that evaluates to the number of an open file.
Intexpression:オープン済みファイルを指定する整数表式。(par_id3153990.8)

Use EOF to avoid errors when you attempt to get input past the end of a file. When you use the Input or Get statement to read from a file, the file pointer is advanced by the number of bytes read. When the end of a file is reached, EOF returns the value "True" (-1).
ファイルの末尾を超えてデータを書き込もうとするとエラーが発生しますが、これを防止するには EOF 関数を使用できます。ファイル中のデータを Input ないし Get ステートメントを用いて読み取る場合は、読み込んだデータのバイト数だけファイルポインタの値が更新されます。そしてファイル末尾に到達すると、EOF 関数は「True」(-1) を返します。(par_id3153527.9)

(embed text/sbasic/shared/00000003.xhp#errorcode : linkinfo)

Error Codes

エラーコード(hd_id3152869.37)

(/embed text/sbasic/shared/00000003.xhp#errorcode)

(embed text/sbasic/shared/00000003.xhp#err5 : linkinfo)

5 Invalid procedure call
5 無効なプロシージャー呼び出しです (par_id3150891.41)

(/embed text/sbasic/shared/00000003.xhp#err5)

(embed text/sbasic/shared/00000003.xhp#err52 : linkinfo)

52 Bad file name or number
52 ファイル名または番号が不正です(par_id3154404.58)

(/embed text/sbasic/shared/00000003.xhp#err52)

Example:
例:(hd_id3154046.10)

Sub ExampleWorkWithAFile
Sub ExampleWorkWithAFile(par_id3143270.11)

Dim iNumber As Integer
Dim iNumber As Integer(par_id3150670.12)

Dim sLine As String
Dim sLine As String(par_id3154143.13)

Dim aFile As String
Dim aFile As String(par_id3148943.14)

Dim sMsg as String
Dim sMsg as String(par_id3153897.37)

aFile = "c:\data.txt"
aFile = "c:\data.txt"(par_id3156344.15)

iNumber = Freefile
iNumber = Freefile(par_id3148663.17)

Open aFile For Output As #iNumber
Open aFile For Output As #iNumber(par_id3153379.18)

Print #iNumber, "First line of text"
Print #iNumber, "First line of text"(par_id3153360.19)

Print #iNumber, "Another line of text"
Print #iNumber, "Another line of text"(par_id3148797.20)

Close #iNumber
Close #iNumber(par_id3154684.21)

iNumber = Freefile
iNumber = Freefile(par_id3153104.25)

Open aFile For Input As iNumber
Open aFile For Input As iNumber(par_id3144761.26)

While not eof(iNumber)
While not eof(iNumber)(par_id3153193.27)

Line Input #iNumber, sLine
Line Input #iNumber, sLine(par_id3158408.28)

If sLine <>"" then
If sLine <>"" then(par_id3149203.29)

sMsg = sMsg & sLine & chr(13)
sMsg = sMsg & sLine & chr(13)(par_id3153770.30)

end if
end if(par_id3153367.32)

wend
Wend(par_id3147318.33)

Close #iNumber
Close #iNumber(par_id3152939.34)

Msgbox sMsg
Msgbox sMsg(par_id3153726.38)

End Sub
End Sub(par_id3153092.35)


< Prev / Next >